//
//  HOStatusEntity.m
//  微度报修
//
//  Created by foguo-mac-1 on 7/10/16.
//  Copyright © 2016 WeiDu. All rights reserved.
//

#import "HOStatusEntity.h"
#import "HOConstants.h"
#import "HOUtils.h"

@implementation HOStatusEntity
- (instancetype)init
{
	self = [super init];
	if(self)
	{
		self.subStatusList = [[[NSMutableArray alloc] init] autorelease];
		self.subStatusDic = [[[NSMutableDictionary alloc] init] autorelease];
	}
	return self;
}

- (void)dealloc
{
	[self.subStatusList removeAllObjects];
	[self.subStatusDic removeAllObjects];
	self.subStatusList = nil;
	self.repairmanName = nil;
	[super dealloc];
}

- (void)parseDic:(NSDictionary *)dic
{
	
	self.orderId = [[dic objectForKey:kHO_FIELD_OrderId] intValue];
	self.orderSN = [[dic objectForKey:kHO_FIELD_OrderSn] intValue];
	self.createTime = [[dic objectForKey:kHO_FIELD_CreateTime] doubleValue];
	self.address = [HOUtils getValideString: [dic objectForKey:kHO_FIELD_FaultAddress]];
	self.detail = [HOUtils getValideString:[dic objectForKey:kHO_FIELD_FaultDetail]];
	self.image = [dic objectForKey:kHO_FIELD_FaultImage];
	
	self.repairmanDepName = [dic objectForKey:kHO_FIELD_RepairmanDepName];
	self.repairmanHeadpic = [dic objectForKey:kHO_FIELD_RepairmanHeadpic];
	self.repairmanId = [[dic objectForKey:kHO_FIELD_RepairmanId] intValue];
	self.repairmanInfo = [dic objectForKey:kHO_FIELD_RepairmanInfo];
	self.repairmanMobile = [dic objectForKey:kHO_FIELD_RepairmanMobile];
	self.repairmanMobile = [HOUtils getValideString:self.repairmanMobile];
	self.repairmanName = [dic objectForKey:kHO_FIELD_RepairmanName];
	self.status = [[dic objectForKey:kHO_FIELD_Status] intValue];
	self.virtualCellPhone = [HOUtils getValideString:[dic objectForKey:kHO_FIELD_VirtualCellPhone]];
	self.isWorking = [[HOUtils getValideString:[dic objectForKey:kHO_FIELD_WorkStatus]] intValue] == 1; //1在线，2离线;
	NSArray *array = [dic objectForKey:kHO_FIELD_RepairmanInfo];
	
	[self.subStatusList removeAllObjects];
	for(int i = 0; i < [array count]; i ++)
	{
		NSDictionary *statusDic = [array objectAtIndex:i];
		HOStatusEntity *entity = [[HOStatusEntity alloc] init];
		entity.createTime = [[dic objectForKey:kHO_FIELD_CreateTime] doubleValue];
		entity.repairmanName = [statusDic objectForKey:kHO_FIELD_RepairmanName];
		entity.status = [[statusDic objectForKey:kHO_FIELD_Status] intValue];
		[self.subStatusList addObject:entity];
		[self.subStatusDic setObject:entity forKey:[NSString stringWithFormat:@"%d", entity.status]];
		[entity release];
	}
	
}
@end
